<template>
  <div class="consortium-head">
    <span
      v-for="(item, index) in projectType"
      :class="projectActive == index ? 'active' : ''"
      :key="item"
      @click="onProject(index, item.value)"
      >{{ item.name }}</span
    >
  </div>
  <el-table border :data="list" style="width: 100%; margin-top: 40px">
    <el-table-column property="id" width="80" label="编号" align="center" />
    <el-table-column
      property="lianhetimingcheng"
      label="联合体名称"
      align="center"
    />
    <el-table-column
      property="zhuliren"
      label="联合体主理人"
      align="center"
    />
    <el-table-column property="leixing1" label="一级分类" align="center" />
    <el-table-column property="leixing2" label="二级分类" align="center" />
    <el-table-column property="canyugongsi" label="参与公司数量" align="center" />
    <el-table-column property="fabugongsi" label="发布公司名称" align="center" />
    <el-table-column property="createTime" label="发布时间" align="center" />
    <el-table-column label="操作" width="80" align="center">
      <template #default="scope">
        <el-button
          style="min-width: auto"
          link
          type="primary"
          size="small"
          @click.prevent="onOperation(scope.row)"
          >详情</el-button
        >
      </template>
    </el-table-column>
  </el-table>
  <h-page
    v-if="total"
    v-model:curr-page="params.current"
    :size="params.size"
    :total="total"
    @change="GetList"
  />
</template>
<script setup>
import { ref, defineProps } from "vue";
import { GetConsortiumInfo } from "@/api/user";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  yhNo: {
    type: String,
    default: "",
  },
});
const params = ref({
  yhNo: props.yhNo,
  renyuanleixing: "fabu",
  current: 1,
  size: 10,
});
// 用户
const projectActive = ref(0);
const projectType = [
  { name: "我发布的", value: "fabu" },
  { name: "我参与的", value: "canyu" },
];
const list = ref([]);
const total = ref(0);
const onProject = (index, value) => {
  projectActive.value = index;
  params.value.renyuanleixing = value;
  GetList();
};
// 操作
const onOperation = (row) => {
  router.push({
    path: `/lianheti/detail`,
    query: {
      id: row.id,
    },
  });
};
// 我发布的
const GetList = () => {
  GetConsortiumInfo(params.value).then((res) => {
    if (res.code == 4201) {
      list.value = res.data.records;
      total.value = res.data.total;
    }
  });
};
GetList();
</script>
<style scope lang="scss">
.consortium-head {
  margin-top: 20px;
  span {
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    color: #333;
    &:not(:first-child) {
      margin-left: 40px;
    }
    &.active {
      color: skyblue;
    }
  }
}
</style>
